using System;
using System.ComponentModel;
using System.Data;
using System.Windows.Forms;
using PCSComProduct.Costing.BO;
using PCSComProduct.Costing.DS;
using PCSComUtils.Common;
using PCSComUtils.PCSExc;
using PCSUtils.Log;
using PCSUtils.Utils;

namespace PCSProduct.Items
{
	/// <summary>
	/// Summary description for ItemCostDetailMaintenance.
	/// </summary>
	public class ItemCostDetailMaintenance : System.Windows.Forms.Form
	{

		#region Variables

		private const string THIS = "PCSProduct.Items.ItemCostDetailMaintenance";
		private const string COST_DESCRIPTION = "Cost description";
		private const string COST_ITEM = "Item cost";
		private const int DECIMALS = 2;

		private DataTable dtbData = new DataTable();
		private ITM_CostDescriptionVO voCostDesc;
		private ITM_CostVO voCost;
		private bool blnIsChanged;
		private int mProductID;
		private bool mMake;
		private int mCCNID;
		/// <summary>
		/// Set CCNID to search Item cost
		/// </summary>
		public int CCNID
		{
			set{mCCNID = value;}
			get{return mCCNID;}
		}
		/// <summary>
		/// Set ProductID to search Item cost
		/// </summary>
		public int ProductID
		{
			set{mProductID = value;}
			get{return mProductID;}
		}
		/// <summary>
		/// If the product is make item then set this property is true otherwise Make=false
		/// </summary>
		public bool Make
		{
			set{mMake = value;}
			get{return mMake;}
		}
		#endregion

		#region Windows Form Designer generated code

		private System.Windows.Forms.Button btnClose;
		private C1.Win.C1TrueDBGrid.C1TrueDBGrid gridData;
		private System.Windows.Forms.Button btnSave;
		private System.Windows.Forms.Label lblCostDesc21;
		private C1.Win.C1Input.C1NumericEdit txtItemCostAmount21;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public ItemCostDetailMaintenance()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ItemCostDetailMaintenance));
			this.btnClose = new System.Windows.Forms.Button();
			this.gridData = new C1.Win.C1TrueDBGrid.C1TrueDBGrid();
			this.lblCostDesc21 = new System.Windows.Forms.Label();
			this.btnSave = new System.Windows.Forms.Button();
			this.txtItemCostAmount21 = new C1.Win.C1Input.C1NumericEdit();
			((System.ComponentModel.ISupportInitialize)(this.gridData)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.txtItemCostAmount21)).BeginInit();
			this.SuspendLayout();
			// 
			// btnClose
			// 
			this.btnClose.AccessibleDescription = resources.GetString("btnClose.AccessibleDescription");
			this.btnClose.AccessibleName = resources.GetString("btnClose.AccessibleName");
			this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnClose.Anchor")));
			this.btnClose.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnClose.BackgroundImage")));
			this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnClose.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnClose.Dock")));
			this.btnClose.Enabled = ((bool)(resources.GetObject("btnClose.Enabled")));
			this.btnClose.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnClose.FlatStyle")));
			this.btnClose.Font = ((System.Drawing.Font)(resources.GetObject("btnClose.Font")));
			this.btnClose.Image = ((System.Drawing.Image)(resources.GetObject("btnClose.Image")));
			this.btnClose.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnClose.ImageAlign")));
			this.btnClose.ImageIndex = ((int)(resources.GetObject("btnClose.ImageIndex")));
			this.btnClose.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnClose.ImeMode")));
			this.btnClose.Location = ((System.Drawing.Point)(resources.GetObject("btnClose.Location")));
			this.btnClose.Name = "btnClose";
			this.btnClose.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnClose.RightToLeft")));
			this.btnClose.Size = ((System.Drawing.Size)(resources.GetObject("btnClose.Size")));
			this.btnClose.TabIndex = ((int)(resources.GetObject("btnClose.TabIndex")));
			this.btnClose.Text = resources.GetString("btnClose.Text");
			this.btnClose.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnClose.TextAlign")));
			this.btnClose.Visible = ((bool)(resources.GetObject("btnClose.Visible")));
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// gridData
			// 
			this.gridData.AccessibleDescription = resources.GetString("gridData.AccessibleDescription");
			this.gridData.AccessibleName = resources.GetString("gridData.AccessibleName");
			this.gridData.AllowAddNew = ((bool)(resources.GetObject("gridData.AllowAddNew")));
			this.gridData.AllowArrows = ((bool)(resources.GetObject("gridData.AllowArrows")));
			this.gridData.AllowColMove = ((bool)(resources.GetObject("gridData.AllowColMove")));
			this.gridData.AllowColSelect = ((bool)(resources.GetObject("gridData.AllowColSelect")));
			this.gridData.AllowDelete = ((bool)(resources.GetObject("gridData.AllowDelete")));
			this.gridData.AllowDrag = ((bool)(resources.GetObject("gridData.AllowDrag")));
			this.gridData.AllowFilter = ((bool)(resources.GetObject("gridData.AllowFilter")));
			this.gridData.AllowHorizontalSplit = ((bool)(resources.GetObject("gridData.AllowHorizontalSplit")));
			this.gridData.AllowRowSelect = ((bool)(resources.GetObject("gridData.AllowRowSelect")));
			this.gridData.AllowSort = ((bool)(resources.GetObject("gridData.AllowSort")));
			this.gridData.AllowUpdate = ((bool)(resources.GetObject("gridData.AllowUpdate")));
			this.gridData.AllowUpdateOnBlur = ((bool)(resources.GetObject("gridData.AllowUpdateOnBlur")));
			this.gridData.AllowVerticalSplit = ((bool)(resources.GetObject("gridData.AllowVerticalSplit")));
			this.gridData.AlternatingRows = ((bool)(resources.GetObject("gridData.AlternatingRows")));
			this.gridData.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("gridData.Anchor")));
			this.gridData.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("gridData.BackgroundImage")));
			this.gridData.BorderStyle = ((System.Windows.Forms.BorderStyle)(resources.GetObject("gridData.BorderStyle")));
			this.gridData.Caption = resources.GetString("gridData.Caption");
			this.gridData.CaptionHeight = ((int)(resources.GetObject("gridData.CaptionHeight")));
			this.gridData.CellTipsDelay = ((int)(resources.GetObject("gridData.CellTipsDelay")));
			this.gridData.CellTipsWidth = ((int)(resources.GetObject("gridData.CellTipsWidth")));
			this.gridData.ChildGrid = ((C1.Win.C1TrueDBGrid.C1TrueDBGrid)(resources.GetObject("gridData.ChildGrid")));
			this.gridData.CollapseColor = ((System.Drawing.Color)(resources.GetObject("gridData.CollapseColor")));
			this.gridData.ColumnFooters = ((bool)(resources.GetObject("gridData.ColumnFooters")));
			this.gridData.ColumnHeaders = ((bool)(resources.GetObject("gridData.ColumnHeaders")));
			this.gridData.DefColWidth = ((int)(resources.GetObject("gridData.DefColWidth")));
			this.gridData.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("gridData.Dock")));
			this.gridData.EditDropDown = ((bool)(resources.GetObject("gridData.EditDropDown")));
			this.gridData.EmptyRows = ((bool)(resources.GetObject("gridData.EmptyRows")));
			this.gridData.Enabled = ((bool)(resources.GetObject("gridData.Enabled")));
			this.gridData.ExpandColor = ((System.Drawing.Color)(resources.GetObject("gridData.ExpandColor")));
			this.gridData.ExposeCellMode = ((C1.Win.C1TrueDBGrid.ExposeCellModeEnum)(resources.GetObject("gridData.ExposeCellMode")));
			this.gridData.ExtendRightColumn = ((bool)(resources.GetObject("gridData.ExtendRightColumn")));
			this.gridData.FetchRowStyles = ((bool)(resources.GetObject("gridData.FetchRowStyles")));
			this.gridData.FilterBar = ((bool)(resources.GetObject("gridData.FilterBar")));
			this.gridData.FlatStyle = ((C1.Win.C1TrueDBGrid.FlatModeEnum)(resources.GetObject("gridData.FlatStyle")));
			this.gridData.Font = ((System.Drawing.Font)(resources.GetObject("gridData.Font")));
			this.gridData.GroupByAreaVisible = ((bool)(resources.GetObject("gridData.GroupByAreaVisible")));
			this.gridData.GroupByCaption = resources.GetString("gridData.GroupByCaption");
			this.gridData.Images.Add(((System.Drawing.Image)(resources.GetObject("resource"))));
			this.gridData.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("gridData.ImeMode")));
			this.gridData.LinesPerRow = ((int)(resources.GetObject("gridData.LinesPerRow")));
			this.gridData.Location = ((System.Drawing.Point)(resources.GetObject("gridData.Location")));
			this.gridData.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder;
			this.gridData.Name = "gridData";
			this.gridData.PictureAddnewRow = ((System.Drawing.Image)(resources.GetObject("gridData.PictureAddnewRow")));
			this.gridData.PictureCurrentRow = ((System.Drawing.Image)(resources.GetObject("gridData.PictureCurrentRow")));
			this.gridData.PictureFilterBar = ((System.Drawing.Image)(resources.GetObject("gridData.PictureFilterBar")));
			this.gridData.PictureFooterRow = ((System.Drawing.Image)(resources.GetObject("gridData.PictureFooterRow")));
			this.gridData.PictureHeaderRow = ((System.Drawing.Image)(resources.GetObject("gridData.PictureHeaderRow")));
			this.gridData.PictureModifiedRow = ((System.Drawing.Image)(resources.GetObject("gridData.PictureModifiedRow")));
			this.gridData.PictureStandardRow = ((System.Drawing.Image)(resources.GetObject("gridData.PictureStandardRow")));
			this.gridData.PreviewInfo.AllowSizing = ((bool)(resources.GetObject("gridData.PreviewInfo.AllowSizing")));
			this.gridData.PreviewInfo.Caption = resources.GetString("gridData.PreviewInfo.Caption");
			this.gridData.PreviewInfo.Location = ((System.Drawing.Point)(resources.GetObject("gridData.PreviewInfo.Location")));
			this.gridData.PreviewInfo.Size = ((System.Drawing.Size)(resources.GetObject("gridData.PreviewInfo.Size")));
			this.gridData.PreviewInfo.ToolBars = ((bool)(resources.GetObject("gridData.PreviewInfo.ToolBars")));
			this.gridData.PreviewInfo.UIStrings.Content = ((string[])(resources.GetObject("gridData.PreviewInfo.UIStrings.Content")));
			this.gridData.PreviewInfo.ZoomFactor = ((System.Double)(resources.GetObject("gridData.PreviewInfo.ZoomFactor")));
			this.gridData.PrintInfo.MaxRowHeight = ((int)(resources.GetObject("gridData.PrintInfo.MaxRowHeight")));
			this.gridData.PrintInfo.OwnerDrawPageFooter = ((bool)(resources.GetObject("gridData.PrintInfo.OwnerDrawPageFooter")));
			this.gridData.PrintInfo.OwnerDrawPageHeader = ((bool)(resources.GetObject("gridData.PrintInfo.OwnerDrawPageHeader")));
			this.gridData.PrintInfo.PageFooter = resources.GetString("gridData.PrintInfo.PageFooter");
			this.gridData.PrintInfo.PageFooterHeight = ((int)(resources.GetObject("gridData.PrintInfo.PageFooterHeight")));
			this.gridData.PrintInfo.PageHeader = resources.GetString("gridData.PrintInfo.PageHeader");
			this.gridData.PrintInfo.PageHeaderHeight = ((int)(resources.GetObject("gridData.PrintInfo.PageHeaderHeight")));
			this.gridData.PrintInfo.PrintHorizontalSplits = ((bool)(resources.GetObject("gridData.PrintInfo.PrintHorizontalSplits")));
			this.gridData.PrintInfo.ProgressCaption = resources.GetString("gridData.PrintInfo.ProgressCaption");
			this.gridData.PrintInfo.RepeatColumnFooters = ((bool)(resources.GetObject("gridData.PrintInfo.RepeatColumnFooters")));
			this.gridData.PrintInfo.RepeatColumnHeaders = ((bool)(resources.GetObject("gridData.PrintInfo.RepeatColumnHeaders")));
			this.gridData.PrintInfo.RepeatGridHeader = ((bool)(resources.GetObject("gridData.PrintInfo.RepeatGridHeader")));
			this.gridData.PrintInfo.RepeatSplitHeaders = ((bool)(resources.GetObject("gridData.PrintInfo.RepeatSplitHeaders")));
			this.gridData.PrintInfo.ShowOptionsDialog = ((bool)(resources.GetObject("gridData.PrintInfo.ShowOptionsDialog")));
			this.gridData.PrintInfo.ShowProgressForm = ((bool)(resources.GetObject("gridData.PrintInfo.ShowProgressForm")));
			this.gridData.PrintInfo.ShowSelection = ((bool)(resources.GetObject("gridData.PrintInfo.ShowSelection")));
			this.gridData.PrintInfo.UseGridColors = ((bool)(resources.GetObject("gridData.PrintInfo.UseGridColors")));
			this.gridData.RecordSelectors = ((bool)(resources.GetObject("gridData.RecordSelectors")));
			this.gridData.RecordSelectorWidth = ((int)(resources.GetObject("gridData.RecordSelectorWidth")));
			this.gridData.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("gridData.RightToLeft")));
			this.gridData.RowDivider.Color = ((System.Drawing.Color)(resources.GetObject("resource.Color")));
			this.gridData.RowDivider.Style = ((C1.Win.C1TrueDBGrid.LineStyleEnum)(resources.GetObject("resource.Style")));
			this.gridData.RowHeight = ((int)(resources.GetObject("gridData.RowHeight")));
			this.gridData.RowSubDividerColor = ((System.Drawing.Color)(resources.GetObject("gridData.RowSubDividerColor")));
			this.gridData.ScrollTips = ((bool)(resources.GetObject("gridData.ScrollTips")));
			this.gridData.ScrollTrack = ((bool)(resources.GetObject("gridData.ScrollTrack")));
			this.gridData.Size = ((System.Drawing.Size)(resources.GetObject("gridData.Size")));
			this.gridData.SpringMode = ((bool)(resources.GetObject("gridData.SpringMode")));
			this.gridData.TabAcrossSplits = ((bool)(resources.GetObject("gridData.TabAcrossSplits")));
			this.gridData.TabIndex = ((int)(resources.GetObject("gridData.TabIndex")));
			this.gridData.Text = resources.GetString("gridData.Text");
			this.gridData.ViewCaptionWidth = ((int)(resources.GetObject("gridData.ViewCaptionWidth")));
			this.gridData.ViewColumnWidth = ((int)(resources.GetObject("gridData.ViewColumnWidth")));
			this.gridData.Visible = ((bool)(resources.GetObject("gridData.Visible")));
			this.gridData.WrapCellPointer = ((bool)(resources.GetObject("gridData.WrapCellPointer")));
			this.gridData.ColEdit += new C1.Win.C1TrueDBGrid.ColEventHandler(this.gridData_ColEdit);
			this.gridData.BeforeColEdit += new C1.Win.C1TrueDBGrid.BeforeColEditEventHandler(this.gridData_BeforeColEdit);
			this.gridData.AfterColEdit += new C1.Win.C1TrueDBGrid.ColEventHandler(this.gridData_AfterColEdit);
			this.gridData.BeforeColUpdate += new C1.Win.C1TrueDBGrid.BeforeColUpdateEventHandler(this.gridData_BeforeColUpdate);
			this.gridData.PropBag = resources.GetString("gridData.PropBag");
			// 
			// lblCostDesc21
			// 
			this.lblCostDesc21.AccessibleDescription = resources.GetString("lblCostDesc21.AccessibleDescription");
			this.lblCostDesc21.AccessibleName = resources.GetString("lblCostDesc21.AccessibleName");
			this.lblCostDesc21.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblCostDesc21.Anchor")));
			this.lblCostDesc21.AutoSize = ((bool)(resources.GetObject("lblCostDesc21.AutoSize")));
			this.lblCostDesc21.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblCostDesc21.Dock")));
			this.lblCostDesc21.Enabled = ((bool)(resources.GetObject("lblCostDesc21.Enabled")));
			this.lblCostDesc21.Font = ((System.Drawing.Font)(resources.GetObject("lblCostDesc21.Font")));
			this.lblCostDesc21.Image = ((System.Drawing.Image)(resources.GetObject("lblCostDesc21.Image")));
			this.lblCostDesc21.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblCostDesc21.ImageAlign")));
			this.lblCostDesc21.ImageIndex = ((int)(resources.GetObject("lblCostDesc21.ImageIndex")));
			this.lblCostDesc21.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblCostDesc21.ImeMode")));
			this.lblCostDesc21.Location = ((System.Drawing.Point)(resources.GetObject("lblCostDesc21.Location")));
			this.lblCostDesc21.Name = "lblCostDesc21";
			this.lblCostDesc21.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblCostDesc21.RightToLeft")));
			this.lblCostDesc21.Size = ((System.Drawing.Size)(resources.GetObject("lblCostDesc21.Size")));
			this.lblCostDesc21.TabIndex = ((int)(resources.GetObject("lblCostDesc21.TabIndex")));
			this.lblCostDesc21.Text = resources.GetString("lblCostDesc21.Text");
			this.lblCostDesc21.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblCostDesc21.TextAlign")));
			this.lblCostDesc21.Visible = ((bool)(resources.GetObject("lblCostDesc21.Visible")));
			// 
			// btnSave
			// 
			this.btnSave.AccessibleDescription = resources.GetString("btnSave.AccessibleDescription");
			this.btnSave.AccessibleName = resources.GetString("btnSave.AccessibleName");
			this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnSave.Anchor")));
			this.btnSave.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnSave.BackgroundImage")));
			this.btnSave.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnSave.Dock")));
			this.btnSave.Enabled = ((bool)(resources.GetObject("btnSave.Enabled")));
			this.btnSave.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnSave.FlatStyle")));
			this.btnSave.Font = ((System.Drawing.Font)(resources.GetObject("btnSave.Font")));
			this.btnSave.Image = ((System.Drawing.Image)(resources.GetObject("btnSave.Image")));
			this.btnSave.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSave.ImageAlign")));
			this.btnSave.ImageIndex = ((int)(resources.GetObject("btnSave.ImageIndex")));
			this.btnSave.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnSave.ImeMode")));
			this.btnSave.Location = ((System.Drawing.Point)(resources.GetObject("btnSave.Location")));
			this.btnSave.Name = "btnSave";
			this.btnSave.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnSave.RightToLeft")));
			this.btnSave.Size = ((System.Drawing.Size)(resources.GetObject("btnSave.Size")));
			this.btnSave.TabIndex = ((int)(resources.GetObject("btnSave.TabIndex")));
			this.btnSave.Text = resources.GetString("btnSave.Text");
			this.btnSave.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSave.TextAlign")));
			this.btnSave.Visible = ((bool)(resources.GetObject("btnSave.Visible")));
			this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
			// 
			// txtItemCostAmount21
			// 
			this.txtItemCostAmount21.AcceptsEscape = ((bool)(resources.GetObject("txtItemCostAmount21.AcceptsEscape")));
			this.txtItemCostAmount21.AccessibleDescription = resources.GetString("txtItemCostAmount21.AccessibleDescription");
			this.txtItemCostAmount21.AccessibleName = resources.GetString("txtItemCostAmount21.AccessibleName");
			this.txtItemCostAmount21.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("txtItemCostAmount21.Anchor")));
			this.txtItemCostAmount21.AutoSize = ((bool)(resources.GetObject("txtItemCostAmount21.AutoSize")));
			this.txtItemCostAmount21.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("txtItemCostAmount21.BackgroundImage")));
			this.txtItemCostAmount21.BorderStyle = ((System.Windows.Forms.BorderStyle)(resources.GetObject("txtItemCostAmount21.BorderStyle")));
			// 
			// txtItemCostAmount21.Calculator
			// 
			this.txtItemCostAmount21.Calculator.AccessibleDescription = resources.GetString("txtItemCostAmount21.Calculator.AccessibleDescription");
			this.txtItemCostAmount21.Calculator.AccessibleName = resources.GetString("txtItemCostAmount21.Calculator.AccessibleName");
			this.txtItemCostAmount21.Calculator.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("txtItemCostAmount21.Calculator.BackgroundImage")));
			this.txtItemCostAmount21.Calculator.ButtonFlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("txtItemCostAmount21.Calculator.ButtonFlatStyle")));
			this.txtItemCostAmount21.Calculator.DisplayFormat = resources.GetString("txtItemCostAmount21.Calculator.DisplayFormat");
			this.txtItemCostAmount21.Calculator.Font = ((System.Drawing.Font)(resources.GetObject("txtItemCostAmount21.Calculator.Font")));
			this.txtItemCostAmount21.Calculator.FormatOnClose = ((bool)(resources.GetObject("txtItemCostAmount21.Calculator.FormatOnClose")));
			this.txtItemCostAmount21.Calculator.StoredFormat = resources.GetString("txtItemCostAmount21.Calculator.StoredFormat");
			this.txtItemCostAmount21.Calculator.UIStrings.Content = ((string[])(resources.GetObject("txtItemCostAmount21.Calculator.UIStrings.Content")));
			this.txtItemCostAmount21.CaseSensitive = ((bool)(resources.GetObject("txtItemCostAmount21.CaseSensitive")));
			this.txtItemCostAmount21.Culture = ((int)(resources.GetObject("txtItemCostAmount21.Culture")));
			this.txtItemCostAmount21.CustomFormat = resources.GetString("txtItemCostAmount21.CustomFormat");
			this.txtItemCostAmount21.DataType = ((System.Type)(resources.GetObject("txtItemCostAmount21.DataType")));
			this.txtItemCostAmount21.DisplayFormat.CustomFormat = resources.GetString("txtItemCostAmount21.DisplayFormat.CustomFormat");
			this.txtItemCostAmount21.DisplayFormat.FormatType = ((C1.Win.C1Input.FormatTypeEnum)(resources.GetObject("txtItemCostAmount21.DisplayFormat.FormatType")));
			this.txtItemCostAmount21.DisplayFormat.Inherit = ((C1.Win.C1Input.FormatInfoInheritFlags)(resources.GetObject("txtItemCostAmount21.DisplayFormat.Inherit")));
			this.txtItemCostAmount21.DisplayFormat.NullText = resources.GetString("txtItemCostAmount21.DisplayFormat.NullText");
			this.txtItemCostAmount21.DisplayFormat.TrimEnd = ((bool)(resources.GetObject("txtItemCostAmount21.DisplayFormat.TrimEnd")));
			this.txtItemCostAmount21.DisplayFormat.TrimStart = ((bool)(resources.GetObject("txtItemCostAmount21.DisplayFormat.TrimStart")));
			this.txtItemCostAmount21.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("txtItemCostAmount21.Dock")));
			this.txtItemCostAmount21.DropDownFormAlign = ((C1.Win.C1Input.DropDownFormAlignmentEnum)(resources.GetObject("txtItemCostAmount21.DropDownFormAlign")));
			this.txtItemCostAmount21.EditFormat.CustomFormat = resources.GetString("txtItemCostAmount21.EditFormat.CustomFormat");
			this.txtItemCostAmount21.EditFormat.FormatType = ((C1.Win.C1Input.FormatTypeEnum)(resources.GetObject("txtItemCostAmount21.EditFormat.FormatType")));
			this.txtItemCostAmount21.EditFormat.Inherit = ((C1.Win.C1Input.FormatInfoInheritFlags)(resources.GetObject("txtItemCostAmount21.EditFormat.Inherit")));
			this.txtItemCostAmount21.EditFormat.NullText = resources.GetString("txtItemCostAmount21.EditFormat.NullText");
			this.txtItemCostAmount21.EditFormat.TrimEnd = ((bool)(resources.GetObject("txtItemCostAmount21.EditFormat.TrimEnd")));
			this.txtItemCostAmount21.EditFormat.TrimStart = ((bool)(resources.GetObject("txtItemCostAmount21.EditFormat.TrimStart")));
			this.txtItemCostAmount21.EditMask = resources.GetString("txtItemCostAmount21.EditMask");
			this.txtItemCostAmount21.EmptyAsNull = ((bool)(resources.GetObject("txtItemCostAmount21.EmptyAsNull")));
			this.txtItemCostAmount21.Enabled = ((bool)(resources.GetObject("txtItemCostAmount21.Enabled")));
			this.txtItemCostAmount21.ErrorInfo.BeepOnError = ((bool)(resources.GetObject("txtItemCostAmount21.ErrorInfo.BeepOnError")));
			this.txtItemCostAmount21.ErrorInfo.ErrorMessage = resources.GetString("txtItemCostAmount21.ErrorInfo.ErrorMessage");
			this.txtItemCostAmount21.ErrorInfo.ErrorMessageCaption = resources.GetString("txtItemCostAmount21.ErrorInfo.ErrorMessageCaption");
			this.txtItemCostAmount21.ErrorInfo.ShowErrorMessage = ((bool)(resources.GetObject("txtItemCostAmount21.ErrorInfo.ShowErrorMessage")));
			this.txtItemCostAmount21.ErrorInfo.ValueOnError = ((object)(resources.GetObject("txtItemCostAmount21.ErrorInfo.ValueOnError")));
			this.txtItemCostAmount21.Font = ((System.Drawing.Font)(resources.GetObject("txtItemCostAmount21.Font")));
			this.txtItemCostAmount21.FormatType = ((C1.Win.C1Input.FormatTypeEnum)(resources.GetObject("txtItemCostAmount21.FormatType")));
			this.txtItemCostAmount21.GapHeight = ((int)(resources.GetObject("txtItemCostAmount21.GapHeight")));
			this.txtItemCostAmount21.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("txtItemCostAmount21.ImeMode")));
			this.txtItemCostAmount21.Increment = ((object)(resources.GetObject("txtItemCostAmount21.Increment")));
			this.txtItemCostAmount21.InitialSelection = ((C1.Win.C1Input.InitialSelectionEnum)(resources.GetObject("txtItemCostAmount21.InitialSelection")));
			this.txtItemCostAmount21.Location = ((System.Drawing.Point)(resources.GetObject("txtItemCostAmount21.Location")));
			this.txtItemCostAmount21.MaskInfo.AutoTabWhenFilled = ((bool)(resources.GetObject("txtItemCostAmount21.MaskInfo.AutoTabWhenFilled")));
			this.txtItemCostAmount21.MaskInfo.CaseSensitive = ((bool)(resources.GetObject("txtItemCostAmount21.MaskInfo.CaseSensitive")));
			this.txtItemCostAmount21.MaskInfo.CopyWithLiterals = ((bool)(resources.GetObject("txtItemCostAmount21.MaskInfo.CopyWithLiterals")));
			this.txtItemCostAmount21.MaskInfo.EditMask = resources.GetString("txtItemCostAmount21.MaskInfo.EditMask");
			this.txtItemCostAmount21.MaskInfo.EmptyAsNull = ((bool)(resources.GetObject("txtItemCostAmount21.MaskInfo.EmptyAsNull")));
			this.txtItemCostAmount21.MaskInfo.ErrorMessage = resources.GetString("txtItemCostAmount21.MaskInfo.ErrorMessage");
			this.txtItemCostAmount21.MaskInfo.Inherit = ((C1.Win.C1Input.MaskInfoInheritFlags)(resources.GetObject("txtItemCostAmount21.MaskInfo.Inherit")));
			this.txtItemCostAmount21.MaskInfo.PromptChar = ((char)(resources.GetObject("txtItemCostAmount21.MaskInfo.PromptChar")));
			this.txtItemCostAmount21.MaskInfo.ShowLiterals = ((C1.Win.C1Input.ShowLiteralsEnum)(resources.GetObject("txtItemCostAmount21.MaskInfo.ShowLiterals")));
			this.txtItemCostAmount21.MaskInfo.StoredEmptyChar = ((char)(resources.GetObject("txtItemCostAmount21.MaskInfo.StoredEmptyChar")));
			this.txtItemCostAmount21.MaxLength = ((int)(resources.GetObject("txtItemCostAmount21.MaxLength")));
			this.txtItemCostAmount21.Name = "txtItemCostAmount21";
			this.txtItemCostAmount21.NullText = resources.GetString("txtItemCostAmount21.NullText");
			this.txtItemCostAmount21.ParseInfo.CaseSensitive = ((bool)(resources.GetObject("txtItemCostAmount21.ParseInfo.CaseSensitive")));
			this.txtItemCostAmount21.ParseInfo.CustomFormat = resources.GetString("txtItemCostAmount21.ParseInfo.CustomFormat");
			this.txtItemCostAmount21.ParseInfo.EmptyAsNull = ((bool)(resources.GetObject("txtItemCostAmount21.ParseInfo.EmptyAsNull")));
			this.txtItemCostAmount21.ParseInfo.ErrorMessage = resources.GetString("txtItemCostAmount21.ParseInfo.ErrorMessage");
			this.txtItemCostAmount21.ParseInfo.FormatType = ((C1.Win.C1Input.FormatTypeEnum)(resources.GetObject("txtItemCostAmount21.ParseInfo.FormatType")));
			this.txtItemCostAmount21.ParseInfo.Inherit = ((C1.Win.C1Input.ParseInfoInheritFlags)(resources.GetObject("txtItemCostAmount21.ParseInfo.Inherit")));
			this.txtItemCostAmount21.ParseInfo.NullText = resources.GetString("txtItemCostAmount21.ParseInfo.NullText");
			this.txtItemCostAmount21.ParseInfo.NumberStyle = ((C1.Win.C1Input.NumberStyleFlags)(resources.GetObject("txtItemCostAmount21.ParseInfo.NumberStyle")));
			this.txtItemCostAmount21.ParseInfo.TrimEnd = ((bool)(resources.GetObject("txtItemCostAmount21.ParseInfo.TrimEnd")));
			this.txtItemCostAmount21.ParseInfo.TrimStart = ((bool)(resources.GetObject("txtItemCostAmount21.ParseInfo.TrimStart")));
			this.txtItemCostAmount21.PasswordChar = ((char)(resources.GetObject("txtItemCostAmount21.PasswordChar")));
			this.txtItemCostAmount21.PostValidation.CaseSensitive = ((bool)(resources.GetObject("txtItemCostAmount21.PostValidation.CaseSensitive")));
			this.txtItemCostAmount21.PostValidation.ErrorMessage = resources.GetString("txtItemCostAmount21.PostValidation.ErrorMessage");
			this.txtItemCostAmount21.PostValidation.Inherit = ((C1.Win.C1Input.PostValidationInheritFlags)(resources.GetObject("txtItemCostAmount21.PostValidation.Inherit")));
			this.txtItemCostAmount21.PostValidation.Validation = ((C1.Win.C1Input.PostValidationTypeEnum)(resources.GetObject("txtItemCostAmount21.PostValidation.Validation")));
			this.txtItemCostAmount21.PostValidation.Values = ((System.Array)(resources.GetObject("txtItemCostAmount21.PostValidation.Values")));
			this.txtItemCostAmount21.PostValidation.ValuesExcluded = ((System.Array)(resources.GetObject("txtItemCostAmount21.PostValidation.ValuesExcluded")));
			this.txtItemCostAmount21.PreValidation.CaseSensitive = ((bool)(resources.GetObject("txtItemCostAmount21.PreValidation.CaseSensitive")));
			this.txtItemCostAmount21.PreValidation.ErrorMessage = resources.GetString("txtItemCostAmount21.PreValidation.ErrorMessage");
			this.txtItemCostAmount21.PreValidation.Inherit = ((C1.Win.C1Input.PreValidationInheritFlags)(resources.GetObject("txtItemCostAmount21.PreValidation.Inherit")));
			this.txtItemCostAmount21.PreValidation.ItemSeparator = resources.GetString("txtItemCostAmount21.PreValidation.ItemSeparator");
			this.txtItemCostAmount21.PreValidation.PatternString = resources.GetString("txtItemCostAmount21.PreValidation.PatternString");
			this.txtItemCostAmount21.PreValidation.RegexOptions = ((C1.Win.C1Input.RegexOptionFlags)(resources.GetObject("txtItemCostAmount21.PreValidation.RegexOptions")));
			this.txtItemCostAmount21.PreValidation.TrimEnd = ((bool)(resources.GetObject("txtItemCostAmount21.PreValidation.TrimEnd")));
			this.txtItemCostAmount21.PreValidation.TrimStart = ((bool)(resources.GetObject("txtItemCostAmount21.PreValidation.TrimStart")));
			this.txtItemCostAmount21.PreValidation.Validation = ((C1.Win.C1Input.PreValidationTypeEnum)(resources.GetObject("txtItemCostAmount21.PreValidation.Validation")));
			this.txtItemCostAmount21.ReadOnly = true;
			this.txtItemCostAmount21.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("txtItemCostAmount21.RightToLeft")));
			this.txtItemCostAmount21.ShowFocusRectangle = ((bool)(resources.GetObject("txtItemCostAmount21.ShowFocusRectangle")));
			this.txtItemCostAmount21.Size = ((System.Drawing.Size)(resources.GetObject("txtItemCostAmount21.Size")));
			this.txtItemCostAmount21.TabIndex = ((int)(resources.GetObject("txtItemCostAmount21.TabIndex")));
			this.txtItemCostAmount21.Tag = ((object)(resources.GetObject("txtItemCostAmount21.Tag")));
			this.txtItemCostAmount21.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("txtItemCostAmount21.TextAlign")));
			this.txtItemCostAmount21.TrimEnd = ((bool)(resources.GetObject("txtItemCostAmount21.TrimEnd")));
			this.txtItemCostAmount21.TrimStart = ((bool)(resources.GetObject("txtItemCostAmount21.TrimStart")));
			this.txtItemCostAmount21.UserCultureOverride = ((bool)(resources.GetObject("txtItemCostAmount21.UserCultureOverride")));
			this.txtItemCostAmount21.Value = ((object)(resources.GetObject("txtItemCostAmount21.Value")));
			this.txtItemCostAmount21.VerticalAlign = ((C1.Win.C1Input.VerticalAlignEnum)(resources.GetObject("txtItemCostAmount21.VerticalAlign")));
			this.txtItemCostAmount21.Visible = ((bool)(resources.GetObject("txtItemCostAmount21.Visible")));
			this.txtItemCostAmount21.VisibleButtons = ((C1.Win.C1Input.DropDownControlButtonFlags)(resources.GetObject("txtItemCostAmount21.VisibleButtons")));
			// 
			// ItemCostDetailMaintenance
			// 
			this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
			this.AccessibleName = resources.GetString("$this.AccessibleName");
			this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
			this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
			this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
			this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.CancelButton = this.btnClose;
			this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
			this.Controls.Add(this.txtItemCostAmount21);
			this.Controls.Add(this.lblCostDesc21);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.gridData);
			this.Controls.Add(this.btnSave);
			this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
			this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
			this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
			this.MaximizeBox = false;
			this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
			this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
			this.Name = "ItemCostDetailMaintenance";
			this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
			this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
			this.Text = resources.GetString("$this.Text");
			this.Closing += new System.ComponentModel.CancelEventHandler(this.ItemCostDetailMaintenance_Closing);
			this.Load += new System.EventHandler(this.ItemCostDetailMaintenance_Load);
			((System.ComponentModel.ISupportInitialize)(this.gridData)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.txtItemCostAmount21)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		#region Forms events

		//**************************************************************************              
		///    <Description>
		///       This method uses to load form
		///    </Description>
		///    <Inputs>
		///            
		///    </Inputs>
		///    <Outputs>
		///       
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       Hoang Trung Son - iSphere software
		///    </Authors>
		///    <History>
		///       Tuesday, March 22, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************
		private void ItemCostDetailMaintenance_Load(object sender, EventArgs e)
		{
			const string METHOD_NAME = THIS + ".ItemCostDetailMaintenance_Load()";
			try
			{
			#region Security
			//Set authorization for user
			Security objSecurity = new Security();
			this.Name = THIS;
			if (objSecurity.SetRightForUserOnForm(this, SystemProperty.UserName) == 0)
			{
				this.Close();
				// You don't have the right to view this item
				PCSMessageBox.Show(ErrorCode.MESSAGE_YOU_HAVE_NO_RIGHT_TO_VIEW, MessageBoxIcon.Warning);
				return;
			}
			#endregion

				InitGrid(mCCNID.ToString());
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}

		//**************************************************************************              
		///    <Description>
		///       This method uses to store data to database
		///    </Description>
		///    <Inputs>
		///            
		///    </Inputs>
		///    <Outputs>
		///       
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       Hoang Trung Son - iSphere software
		///    </Authors>
		///    <History>
		///       Tuesday, March 22, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************
		private void btnSave_Click(object sender, EventArgs e)
		{
			const string METHOD_NAME = THIS + ".btnSave_Click()";
			const int MAX20 = 20;
			try
			{
				if(dtbData.Rows.Count == 0) return;
				if(!blnIsChanged) return;
				CostDescriptionBO boCost = new CostDescriptionBO();

				if (dtbData.Rows.Count == MAX20)
				{
					int intRow = 0;
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostMaterial01 = decimal.Parse(gridData[intRow++, COST_ITEM].ToString());

					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostMaterialOverHead02 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());

					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostMachineSetup03 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());

					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostMachineSetupFixed04 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());

					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostMachineSetupVar05 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostMachineRun06 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostMachineFixed07 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostMachineVariable08 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostLaborSetup09 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostLaborSetupFixed10 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostLaborSetupVariable11 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostLaborRun12 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostLaborFixed13 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostLaborVariable14 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostOutsideProc15 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostAssemblyScrap16 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostShrink17 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());

					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostFreight18 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());

					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostUserStandard1_19 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());

					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostUserStandard2_20 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());

					voCost.ItemCostTotalAmount21 = 0;
					foreach(DataRow drow in dtbData.Rows)
					{
						decimal decValue = 0;
						if(drow[COST_ITEM] != DBNull.Value)
							decValue = decimal.Parse(drow[COST_ITEM].ToString());
						voCost.ItemCostTotalAmount21 += decValue;
					}
				}
				else
				{
					int intRow = 0;
					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostMaterial01 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());

					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostFreight18 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());

					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostUserStandard1_19 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());

					if(gridData[intRow,COST_ITEM] != DBNull.Value)
						voCost.ItemCostUserStandard2_20 = decimal.Parse(gridData[intRow++,COST_ITEM].ToString());
				}

				boCost.UpdateItemCost(voCost);
				PCSMessageBox.Show(ErrorCode.MESSAGE_AFTER_SAVE_DATA,MessageBoxIcon.Information);
				blnIsChanged = false;
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}

		//**************************************************************************              
		///    <Description>
		///       This method uses to canculate total
		///    </Description>
		///    <Inputs>
		///            
		///    </Inputs>
		///    <Outputs>
		///       
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       Hoang Trung Son - iSphere software
		///    </Authors>
		///    <History>
		///       Tuesday, March 22, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************
		private void gridData_RowColChange(object sender, C1.Win.C1TrueDBGrid.RowColChangeEventArgs e)
		{
//			const string METHOD_NAME = THIS + ".gridData_RowColChange()";
//			try
//			{
//				
//			}
//			catch (PCSException ex)
//			{
//				// Displays the error message if throwed from PCSException.
//				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
//				try
//				{
//					// Log error message into log file.
//					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
//				}
//				catch
//				{
//					// Show message if logger has an error.
//					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
//				}
//			}
//			catch (Exception ex)
//			{
//				// Displays the error message if throwed from system.
//				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
//				try
//				{
//					// Log error message into log file.
//					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
//				}
//				catch
//				{
//					// Show message if logger has an error.
//					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
//				}
//			}
		}

		//**************************************************************************              
		///    <Description>
		///       This method uses to 
		///    </Description>
		///    <Inputs>
		///            
		///    </Inputs>
		///    <Outputs>
		///       
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       Hoang Trung Son - iSphere software
		///    </Authors>
		///    <History>
		///       Monday, February 21, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************
		private void ItemCostDetailMaintenance_Closing(object sender, CancelEventArgs e)
		{
			const string METHOD_NAME = THIS + ".ItemCostDetailMaintenance_Closing()";
			try
			{
				if(blnIsChanged)
				{
					// Do you want to Release 
					DialogResult dlgResult = PCSMessageBox.Show(ErrorCode.MESSAGE_QUESTION_STORE_INTO_DATABASE,MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question);
					if(dlgResult == DialogResult.Yes) btnSave_Click(null,null);
					else if(dlgResult == DialogResult.Cancel) e.Cancel = true;
				}
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}
		private void gridData_ColEdit(object sender, C1.Win.C1TrueDBGrid.ColEventArgs e)
		{
			blnIsChanged = true;
		}

		private void btnClose_Click(object sender, EventArgs e)
		{
			Close();
		}
		#endregion

		#region other functions

		//**************************************************************************              
		///    <Description>
		///       This method uses to 
		///    </Description>
		///    <Inputs>
		///            
		///    </Inputs>
		///    <Outputs>
		///       
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       Hoang Trung Son - iSphere software
		///    </Authors>
		///    <History>
		///       Monday, March 21, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************
		private void InitGrid(string pstrCCNID)
		{
			const string METHOD_NAME = THIS + ".InitGrid()";
			const string DECIMAL_FORMAT = "###############,0.00";
			const int WIDTH = 200;
			try
			{
				CostDescriptionBO boCost = new CostDescriptionBO();
				voCostDesc = (ITM_CostDescriptionVO)boCost.GetObjectVO(pstrCCNID);
				voCost = (ITM_CostVO)new ItemCostDetailMaintenanceBO().GetItemCostVO(int.Parse(pstrCCNID), mProductID);
				dtbData.Columns.Add(COST_DESCRIPTION);
				dtbData.Columns.Add(COST_ITEM);
				dtbData.Columns[COST_ITEM].DataType = typeof(decimal);

				// if is make item
				if (mMake)
				{
					object[] objRow01 = {voCostDesc.CostDesc01,voCost.ItemCostMaterial01};
					dtbData.Rows.Add(objRow01);

					object[] objRow02 = {voCostDesc.CostDesc02,voCost.ItemCostMaterialOverHead02};
					dtbData.Rows.Add(objRow02);

					object[] objRow03 = {voCostDesc.CostDesc03,voCost.ItemCostMachineSetup03};
					dtbData.Rows.Add(objRow03);

					object[] objRow04 = {voCostDesc.CostDesc04,voCost.ItemCostMachineSetupFixed04};
					dtbData.Rows.Add(objRow04);

					object[] objRow05 = {voCostDesc.CostDesc05,voCost.ItemCostMachineSetupVar05};
					dtbData.Rows.Add(objRow05);

					object[] objRow06 = {voCostDesc.CostDesc06,voCost.ItemCostMachineRun06};
					dtbData.Rows.Add(objRow06);

					object[] objRow07 = {voCostDesc.CostDesc07,voCost.ItemCostMachineFixed07};
					dtbData.Rows.Add(objRow07);

					object[] objRow08 = {voCostDesc.CostDesc08,voCost.ItemCostMachineVariable08};
					dtbData.Rows.Add(objRow08);

					object[] objRow09 = {voCostDesc.CostDesc09,voCost.ItemCostLaborSetup09};
					dtbData.Rows.Add(objRow09);

					object[] objRow10 = {voCostDesc.CostDesc10,voCost.ItemCostLaborSetupFixed10};
					dtbData.Rows.Add(objRow10);

					object[] objRow11 = {voCostDesc.CostDesc11,voCost.ItemCostLaborSetupVariable11};
					dtbData.Rows.Add(objRow11);

					object[] objRow12 = {voCostDesc.CostDesc12,voCost.ItemCostLaborRun12};
					dtbData.Rows.Add(objRow12);

					object[] objRow13 = {voCostDesc.CostDesc13,voCost.ItemCostLaborFixed13};
					dtbData.Rows.Add(objRow13);

					object[] objRow14 = {voCostDesc.CostDesc14,voCost.ItemCostLaborVariable14};
					dtbData.Rows.Add(objRow14);

					object[] objRow15 = {voCostDesc.CostDesc15,voCost.ItemCostOutsideProc15};
					dtbData.Rows.Add(objRow15);

					object[] objRow16 = {voCostDesc.CostDesc16,voCost.ItemCostAssemblyScrap16};
					dtbData.Rows.Add(objRow16);

					object[] objRow17 = {voCostDesc.CostDesc17,voCost.ItemCostShrink17};
					dtbData.Rows.Add(objRow17);

					object[] objRow18 = {voCostDesc.CostDesc18,voCost.ItemCostFreight18};
					dtbData.Rows.Add(objRow18);

					object[] objRow19 = {voCostDesc.CostDesc19,voCost.ItemCostUserStandard1_19};
					dtbData.Rows.Add(objRow19);

					object[] objRow20 = {voCostDesc.CostDesc20,voCost.ItemCostUserStandard2_20};
					dtbData.Rows.Add(objRow20);

					lblCostDesc21.Text = voCostDesc.CostDesc21;
					txtItemCostAmount21.Value = decimal.Round(voCost.ItemCostTotalAmount21,DECIMALS);
				}
				else
				{
					object[] objRow01 = {voCostDesc.CostDesc01, voCost.ItemCostMaterial01};
					dtbData.Rows.Add(objRow01);

					object[] objRow18 = {voCostDesc.CostDesc18, voCost.ItemCostFreight18};
					dtbData.Rows.Add(objRow18);

					object[] objRow19 = {voCostDesc.CostDesc19, voCost.ItemCostUserStandard1_19};
					dtbData.Rows.Add(objRow19);

					object[] objRow20 = {voCostDesc.CostDesc20, voCost.ItemCostUserStandard2_20};
					dtbData.Rows.Add(objRow20);

//					object[] objRow21 = {voCostDesc.CostDesc21, voCost.ComTotalAmount21};
//					dtbData.Rows.Add(objRow21);

					//lblCostDesc21.Visible = txtItemCostAmount21.Visible = false;
					lblCostDesc21.Text = voCostDesc.CostDesc21;
					txtItemCostAmount21.Value = decimal.Round(voCost.ItemCostTotalAmount21,DECIMALS);

				}
				gridData.DataSource = dtbData;

				gridData.Splits[0].DisplayColumns[COST_DESCRIPTION].Locked = true;
				gridData.Splits[0].DisplayColumns[COST_DESCRIPTION].Width = 
					gridData.Splits[0].DisplayColumns[COST_ITEM].Width = WIDTH;
				gridData.Columns[COST_ITEM].NumberFormat = DECIMAL_FORMAT;
				

			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}


		}

		#endregion

		private void gridData_AfterColEdit(object sender, C1.Win.C1TrueDBGrid.ColEventArgs e)
		{
			try
			{
				if(gridData.Columns[e.ColIndex] != gridData.Columns[COST_ITEM]) return;
				decimal.Parse(e.Column.DataColumn.Text);
				voCost.ItemCostTotalAmount21 = 0;
				foreach(DataRow drow in dtbData.Rows)
				{
					voCost.ItemCostTotalAmount21 += decimal.Parse(drow[COST_ITEM].ToString());
				}
				txtItemCostAmount21.Value = decimal.Round(voCost.ItemCostTotalAmount21,DECIMALS);

			}
			catch
			{
				e.Column.DataColumn.Value = 0;

			}
//			if(decimal.Parse(e.Column.DataColumn.Text) < 0)
//			{
//				e.Column.DataColumn.Value = -decimal.Parse(e.Column.DataColumn.Text);
//			}
		}
		/// <summary>
		/// gridData_BeforeColUpdate
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Monday, October 10 2005</date>
		private void gridData_BeforeColUpdate(object sender, C1.Win.C1TrueDBGrid.BeforeColUpdateEventArgs e)
		{
			const string METHOD_NAME = THIS + ".gridData_BeforeColUpdate()";
			try
			{
				//If value of this column is not a number then can not leave.
				if (e.Column.DataColumn.Text == string.Empty)
					return;
				try
				{
					decimal.Parse(e.Column.DataColumn.Text);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.POSITIVE_NUMBER, MessageBoxIcon.Warning);
					e.Cancel = true;
					return;
				}
				if ((gridData.Row != 18) && (gridData.Row != 19))
				{
					if (decimal.Parse(e.Column.DataColumn.Text) < 0)
					{
						PCSMessageBox.Show(ErrorCode.POSITIVE_NUMBER, MessageBoxIcon.Warning);
						e.Cancel = true;						
					}
				}
			}
			catch (PCSDBException ex) 
			{
				// displays the error message.
				PCSMessageBox.Show(ex.mCode,MessageBoxIcon.Error);
				// log message.
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION,MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// displays the error message.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR,MessageBoxIcon.Error);
				// log message.
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION,MessageBoxIcon.Error);
				}
			}
		
		}
		/// <summary>
		/// gridData_BeforeColEdit
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		///<author>Trada</author>
		///<date>Monday, October 10 2005</date>
		private void gridData_BeforeColEdit(object sender, C1.Win.C1TrueDBGrid.BeforeColEditEventArgs e)
		{
			const string METHOD_NAME = THIS + ".gridData_BeforeColEdit()";
			try
			{
								
			}
			catch (PCSDBException ex) 
			{
				// displays the error message.
				PCSMessageBox.Show(ex.mCode,MessageBoxIcon.Error);
				// log message.
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION,MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// displays the error message.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR,MessageBoxIcon.Error);
				// log message.
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION,MessageBoxIcon.Error);
				}
			}
		
		}

	}
}
